home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-I386 / SMPLOCK.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  1KB  |  60 lines

  1. /*
  2.  * <asm/smplock.h>
  3.  *
  4.  * i386 SMP lock implementation
  5.  */
  6. #include <linux/interrupt.h>
  7. #include <asm/spinlock.h>
  8.  
  9. extern spinlock_t kernel_flag;
  10.  
  11. /*
  12.  * Release global kernel lock and global interrupt lock
  13.  */
  14. #define release_kernel_lock(task, cpu) \
  15. do { \
  16.     if (task->lock_depth >= 0) \
  17.         spin_unlock(&kernel_flag); \
  18.     release_irqlock(cpu); \
  19.     __sti(); \
  20. } while (0)
  21.  
  22. /*
  23.  * Re-acquire the kernel lock
  24.  */
  25. #define reacquire_kernel_lock(task) \
  26. do { \
  27.     if (task->lock_depth >= 0) \
  28.         spin_lock(&kernel_flag); \
  29. } while (0)
  30.  
  31.  
  32. /*
  33.  * Getting the big kernel lock.
  34.  *
  35.  * This cannot happen asynchronously,
  36.  * so we only need to worry about other
  37.  * CPU's.
  38.  */
  39. extern __inline__ void lock_kernel(void)
  40. {
  41.     __asm__ __volatile__(
  42.         "incl %1\n\t"
  43.         "jne 9f"
  44.         spin_lock_string
  45.         "\n9:"
  46.         :"=m" (__dummy_lock(&kernel_flag)),
  47.          "=m" (current->lock_depth));
  48. }
  49.  
  50. extern __inline__ void unlock_kernel(void)
  51. {
  52.     __asm__ __volatile__(
  53.         "decl %1\n\t"
  54.         "jns 9f\n\t"
  55.         spin_unlock_string
  56.         "\n9:"
  57.         :"=m" (__dummy_lock(&kernel_flag)),
  58.          "=m" (current->lock_depth));
  59. }
  60.